ListNode* mergeNodes(ListNode* head) {
        ListNode *p = head->next;

        while(p)
        {
            while(p->next->val != 0)
            {
                p->val += p->next->val;
                p->next = p->next->next;
            }
            p = p->next = p->next->next;
        }
        return head->next;
    }